package com.biz.primus.ms.commodity.service.backend;

import com.biz.primus.commodity.vo.backend.CommodityItemVo;
import com.biz.primus.ms.commodity.dao.po.Product;
import com.google.common.base.Function;
import javax.annotation.Nullable;

/**
 * @author 江南
 * @usage
 * @reviewer
 * @since 2017/3/15
 */
public class Product2CommodityItemVo implements Function<Product, CommodityItemVo> {

    @Nullable
    @Override
    public CommodityItemVo apply(@Nullable Product input) {
        CommodityItemVo respVo = new CommodityItemVo();
        respVo.setId(String.valueOf(input.getId()));
        respVo.setProductCode(input.getProductCode());
        respVo.setProductName(input.getName());
        if (input.getAppSaleStatus() != null) {
            respVo.setAppSaleStatus(input.getAppSaleStatus().getDescription());
        }
        if (input.getWebSaleStatus() != null) {
            respVo.setWebSaleStatus(input.getWebSaleStatus().getDescription());
        }
        respVo.setUpdateTimeStamp(input.getUpdateTimestamp());
        return respVo;
    }

}
